/* Pineapple Blueboard - Assessment Grid script */

$(document).ready(function (){

$("#viewswitch").click(function () {
		var theswitch = $(this);
		if (theswitch.hasClass('d') === false){ //enabled
			var theswitchid = theswitch.attr('id');
			if (theswitch.hasClass('s1')){
			$(theswitch).find(':first-child').animate({ "margin-left": "82px" },300,'easeOutQuart');
			theswitch.removeClass('s1');
			theswitch.addClass('s2');
			$(theswitch).clearQueue();
			//action for command
			$('.assesslist').find('a').animate({ backgroundColor: "#EEE3BB" }, 200);
			
			} else if (theswitch.hasClass('s2')){
			$(theswitch).find(':first-child').animate({ "margin-left": "0px" },300,'easeOutQuart');
			theswitch.removeClass('s2');
			$(theswitch).clearQueue();
			//action for command
			$('.assesslist').find('a').animate({ backgroundColor: "#EED3D1" }, 200);
			
			} else{
			$(theswitch).find(':first-child').animate({ "margin-left": "41px" },300,'easeOutQuart');
			theswitch.addClass('s1');
			$(theswitch).clearQueue();
			//action for command
			$('.assesslist').find('a').animate({ backgroundColor: "#E2E2E9" }, 200);
			
			}
		}
	});

$(".assesslist a").click(function(){
	var urlvar = $(this).attr('href');
	urlvar = urlvar.replace("#", "");
	if($("#viewswitch").hasClass('s1')){
	window.location = 'assessment/view/'+urlvar;
	}else if($("#viewswitch").hasClass('s2')){
	window.location = 'assessment/modify/'+urlvar;
	}else{
	window.location = 'assessment/delete/'+urlvar+'?ap';
	}
	return false;
	});
	
});